package com.xy.test.netty;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;

public class MyWatcher implements Watcher {
    @Override
    public void process(WatchedEvent event) {
        System.out.println("收到事件通知：" + event.getType());

        if (event.getType() == Event.EventType.None) {
            System.out.println("None");
        } else if (event.getType() == Event.EventType.NodeCreated){
            System.out.println("节点被创建，path=" + event.getPath());
        } else if (event.getType() == Event.EventType.NodeDeleted) {
            System.out.println("节点被删除，path=" + event.getPath());
        } else if (event.getType() == Event.EventType.NodeDataChanged) {
            System.out.println("数据发生变化，path=" + event.getPath());
        } else if (event.getType() == Event.EventType.NodeChildrenChanged){
            System.out.println("子节点发生变化，path=" + event.getPath());
        } else if (event.getType() == Event.EventType.DataWatchRemoved){
            System.out.println("数据监听被移除，path=" + event.getPath());
        } else if (event.getType() == Event.EventType.ChildWatchRemoved){
            System.out.println("子节点监听被移除，path=" + event.getPath());
        } else if (event.getType() == Event.EventType.PersistentWatchRemoved){
            System.out.println("持久化监听被移除，path=" + event.getPath());
        }
    }
}